package com.tianji.learning.controller;

import com.tianji.api.dto.leanring.LearningLessonDTO;
import com.tianji.learning.domain.dto.LearningRecordFormDTO;
import com.tianji.learning.service.ILearningRecordService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.context.annotation.Lazy;
import org.springframework.web.bind.annotation.*;

@RestController
@RequestMapping("/learning-records")
@Slf4j
@Api(tags = "学习记录相关接口")
@RequiredArgsConstructor(onConstructor_ = {@Lazy})
public class LearningRecordController {

    private ILearningRecordService learningRecordService;

    /**
     * 查询指定课程的学习记录
     *
     * @param courseId 课程Id
     * @return 课表id 最近学习小节  Array
     */
    @GetMapping("/course/{courseId}")
    @ApiOperation(value = "查询指定课程的学习记录")
    public LearningLessonDTO queryLearningRecordByCourse(
            @ApiParam(value = "课程id", example = "2") @PathVariable("courseId") Long courseId) {
        return learningRecordService.queryLearningRecordByCourse(courseId);
    }

    /**
     * 提交学习记录
     *
     * @param learningRecordFormDTO
     */
    @PostMapping
    @ApiOperation(value = "提交学习记录")
    public void postLearningRecord(@RequestBody LearningRecordFormDTO learningRecordFormDTO) {
        learningRecordService.postLearningRecord(learningRecordFormDTO);
    }


}
